package com.wxsong.authplatform.authweb.util;

import org.apache.shiro.codec.Base64;

public class Base64Util {

    private final static String salt =  "321456987_+asd";

    public static String encode(String str){
        synchronized (salt){
            str += salt;
            return new String(Base64.encode(str.getBytes()));
        }
    }

    public static String decode(String str){
        synchronized (salt){
            str = new String(Base64.decode(str.getBytes()));
            return str.replace(salt, "");
        }
    }

    public static void main(String[] args){
        String s = "1";
        String enc = encode(s);
        System.out.println(s + "====" + enc);

        String dec = decode(enc);
        System.out.println(enc + "====" + dec);
    }
}
